Skip to content

Expose enableOnDemandInstructionDiscovery across all SDK SessionConfig types#1323

Open
examon wants to merge 2 commits into
mainfrom
tmeszaros/sdk-on-demand-instruction-discovery
Open

Expose enableOnDemandInstructionDiscovery across all SDK SessionConfig types#1323
examon wants to merge 2 commits into
mainfrom
tmeszaros/sdk-on-demand-instruction-discovery

Conversation

@examon
Copy link
Copy Markdown

@examon examon commented May 18, 2026

Exposes the new enableOnDemandInstructionDiscovery configuration flag across all five in-repo SDKs (Node, Python, Go, .NET, Rust). Mirrors the precedent set by #1044 (enableConfigDiscovery) and #1295 (remoteSession).

The runtime change shipped in github/copilot#7759 and is available in @github/copilot@^1.0.49-1.

Cross-language consistency matrix

SDK Public field Wire key Create Resume Unset behavior Explicit-false behavior
Node enableOnDemandInstructionDiscovery?: boolean enableOnDemandInstructionDiscovery omitted wire false
Python enable_on_demand_instruction_discovery: bool | None = None enableOnDemandInstructionDiscovery omitted wire false
Go EnableOnDemandInstructionDiscovery *bool enableOnDemandInstructionDiscovery omitted (nil) wire false
.NET bool? EnableOnDemandInstructionDiscovery enableOnDemandInstructionDiscovery omitted (null) wire false
Rust enable_on_demand_instruction_discovery: Option<bool> enableOnDemandInstructionDiscovery omitted (None) wire false

Runtime-gated availability

When set to true, the SDK asks the runtime to discover custom instruction files on demand after the agent successfully reads or views files. The option is runtime-gated: it takes effect only when custom instructions are enabled and the connected runtime supports and enables on-demand custom instruction discovery. Otherwise the runtime accepts the option but performs no on-demand discovery (silent no-op, no error or warning).

The SDK does not attempt to detect runtime gating; it forwards the option unconditionally. On session.resume, omitting the option leaves the existing session setting unchanged, and passing an explicit false disables future on-demand discovery for that resumed session.

Trust and security

Enable only for trusted repositories or workspaces. Discovered instruction files are treated as model instructions, may affect agent behavior, and may be stored or replayed with session history. Do not enable for untrusted content, CI jobs processing untrusted forks, or directories writable by untrusted users or processes.

Go shape

Uses *bool (not bool) on both SessionConfig and ResumeSessionConfig so callers can disable a previously-enabled session on resume. Reuses the precedent already set by EnableSessionTelemetry *bool and IncludeSubAgentStreamingEvents *bool. This PR does not retrofit the existing EnableConfigDiscovery bool field — that would be a separate breaking source change with broader blast radius.

Tests

Each SDK adds tests for the new field on both session.create and session.resume, asserting that explicit false is serialized on the wire and that omission drops the key entirely. Mirrors the test patterns already in place for enable_session_telemetry, include_sub_agent_streaming_events, and enable_config_discovery.

  • Node: extends nodejs/test/e2e/client_options.e2e.test.ts happy-path; adds 2 unit tests in nodejs/test/client.test.ts (create + resume, explicit false).
  • Python: extends python/e2e/test_client_options_e2e.py happy-path; adds 2 unit tests in python/test_client.py (create + resume, explicit False).
  • Go: extends go/internal/e2e/client_options_e2e_test.go happy-path; adds 6 wire-format unit tests in go/client_test.go (create + resume; Bool(true), Bool(false), and omitted).
  • .NET: adds 2 serialization tests in dotnet/test/Unit/SerializationTests.cs (create + resume; true, false, omitted) and 4 clone tests in dotnet/test/Unit/CloneTests.cs covering the copy-ctor.
  • Rust: adds 2 wire-format tests in rust/tests/session_test.rs (create + resume; Some(true), Some(false), omitted) and extends the existing builder unit-tests in rust/src/types.rs to call the new .with_enable_on_demand_instruction_discovery(...) method on both SessionConfig and ResumeSessionConfig.

Documentation

The new field is documented inline in each SDK's typed config surface using the language-appropriate doc-comment style (JSDoc, Google-style, godoc, XML, Rustdoc). README and CHANGELOG are intentionally not updated, matching the precedent of #1044 and #1295.

Notes for reviewers

  • go/types.go shows ~170 line changes; the bulk is gofmt-driven struct-tag column re-alignment because the new field name is longer than any existing field. The only semantic changes are the additions of EnableOnDemandInstructionDiscovery to SessionConfig, ResumeSessionConfig, and the two wire-request structs.
  • The existing enableConfigDiscovery docstring statement that custom instruction files "are always loaded from the working directory regardless of this setting" remains accurate — the new option adds on-demand discovery on top of the up-front load; it does not replace it.
  • python/copilot/session.py TypedDicts do not include the new field. They are also missing existing fields (enable_config_discovery, remote_session); closing those gaps is best handled in a follow-up so this PR stays narrow.

Copilot AI review requested due to automatic review settings May 18, 2026 16:55
@examon examon requested a review from a team as a code owner May 18, 2026 16:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new session configuration flag (enableOnDemandInstructionDiscovery) across the in-repo SDKs so consumers can opt into (or explicitly disable) runtime on-demand custom-instruction discovery via the JSON-RPC wire key enableOnDemandInstructionDiscovery.

Changes:

  • Exposes the new flag on SessionConfig + ResumeSessionConfig surfaces (and forwards it on session.create/session.resume) for Node, Python, Go, .NET, and Rust.
  • Adds/extends unit + E2E coverage to verify true/false serialization and key omission when unset.
  • Adds inline API documentation for the new option in each language’s config surface.
Show a summary per file
File Description
rust/tests/session_test.rs Adds serde wire-format tests for enableOnDemandInstructionDiscovery on SessionConfig/ResumeSessionConfig.
rust/src/types.rs Adds enable_on_demand_instruction_discovery: Option<bool> + builder methods + debug/default updates and unit-test coverage.
python/test_client.py Adds forwarding tests ensuring explicit False is sent on create/resume.
python/e2e/test_client_options_e2e.py Extends E2E options propagation test to include the new flag.
python/copilot/client.py Adds new kwargs to create/resume APIs, docs, and wire payload serialization.
nodejs/test/e2e/client_options.e2e.test.ts Extends E2E options propagation test to assert the new flag is present.
nodejs/test/client.test.ts Adds unit tests verifying forwarding on session.create and session.resume.
nodejs/src/types.ts Adds enableOnDemandInstructionDiscovery?: boolean to SessionConfig and includes it in ResumeSessionConfig pick.
nodejs/src/client.ts Forwards the new flag in create/resume request payloads.
go/types.go Adds *bool config fields and wires them into create/resume request structs (plus gofmt alignment).
go/internal/e2e/client_options_e2e_test.go Extends Go E2E options propagation assertions to include the new flag.
go/client.go Forwards EnableOnDemandInstructionDiscovery into create/resume wire requests.
go/client_test.go Adds wire-format unit tests for explicit true/false and omission behavior.
dotnet/test/Unit/SerializationTests.cs Adds serialization tests validating true/false/omitted behavior for create/resume requests.
dotnet/test/Unit/CloneTests.cs Ensures SessionConfig/ResumeSessionConfig clone operations copy/preserve the new nullable property.
dotnet/src/Types.cs Adds bool? EnableOnDemandInstructionDiscovery to SessionConfig/ResumeSessionConfig and copies it in clone constructors.
dotnet/src/Client.cs Threads the new option through Create/Resume request construction and record types.

Copilot's findings

  • Files reviewed: 17/17 changed files
  • Comments generated: 2

Comment thread python/copilot/client.py Outdated
Comment thread go/types.go Outdated
@github-actions

This comment has been minimized.

Tomas Meszaros and others added 2 commits May 19, 2026 14:24
Mirrors the existing enableConfigDiscovery and remoteSession precedents
(PRs #1044 and #1295). Exposes the SDK option that lets the runtime
discover custom instruction files on demand after the agent reads or
views files, complementing the existing up-front load of
`.github/copilot-instructions.md`, `AGENTS.md`, etc.

Wire key (camelCase, identical across all 5 SDKs):
  enableOnDemandInstructionDiscovery

Type shapes:
  Node    enableOnDemandInstructionDiscovery?: boolean
  Python  enable_on_demand_instruction_discovery: bool | None = None
  Go      EnableOnDemandInstructionDiscovery *bool
  .NET    bool? EnableOnDemandInstructionDiscovery
  Rust    Option<bool> with #[serde(skip_serializing_if = "Option::is_none")]

Wire semantics: when set, the wire payload carries the literal value
(including explicit `false`); when omitted, the key is dropped.
Applies to both session.create and session.resume so callers can
toggle the setting on a resumed session.

Runtime-gated. The runtime honors the option only when custom
instructions are enabled and the connected runtime supports on-demand
custom instruction discovery; otherwise the option is accepted but
no-ops. The SDK does not attempt to detect the runtime gate. Requires
@github/copilot ^1.0.49-1 (the runtime change shipped in
github/copilot#7759).

Security: discovered instruction files are treated as model
instructions and may be stored or replayed with session history.
Docstrings caution against enabling for untrusted content, CI jobs
processing untrusted forks, or directories writable by untrusted
users or processes.

Go shape note: uses *bool (not bool) so consumers can disable a
previously-enabled session on resume. Reuses the precedent already
set by EnableSessionTelemetry *bool and IncludeSubAgentStreamingEvents
*bool. Does not retrofit the existing EnableConfigDiscovery bool field
(that would be a separate breaking source change).

Tests: each SDK adds tests for the new field on both create and
resume, asserting that explicit `false` is serialized as `false` and
that omission drops the key from the payload. Mirrors the test
patterns already in place for enable_session_telemetry,
include_sub_agent_streaming_events, and enable_config_discovery.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Addresses review feedback on PR #1323: the create-session API docs for
enable_on_demand_instruction_discovery / EnableOnDemandInstructionDiscovery
should not include resume-specific behavior. That note already lives on
the resume-side configs (Python resume_session and Go ResumeSessionConfig).
@examon examon force-pushed the tmeszaros/sdk-on-demand-instruction-discovery branch from 07bfd0a to e9e961a Compare May 19, 2026 14:28
@github-actions
Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR consistently exposes enableOnDemandInstructionDiscovery across all five SDKs (Node.js, Python, Go, .NET, Rust). Here's my cross-language consistency check:

Consistency matrix verified

Aspect Node.js Python Go .NET Rust
SessionConfig field enableOnDemandInstructionDiscovery?: boolean enable_on_demand_instruction_discovery: bool | None EnableOnDemandInstructionDiscovery *bool bool? EnableOnDemandInstructionDiscovery enable_on_demand_instruction_discovery: Option<bool>
ResumeSessionConfig field ✅ (via Pick<>)
Wire key enableOnDemandInstructionDiscovery same same same same
Omit-when-unset ✅ (nil) ✅ (null) ✅ (None)
Explicit-false serialized
Builder method with_enable_on_demand_instruction_discovery(bool)
Unit tests
Doc comments

Known gaps (pre-existing, acknowledged in PR description)

  1. Python session.py TypedDictsSessionConfig and ResumeSessionConfig TypedDicts in python/copilot/session.py do not include enable_on_demand_instruction_discovery. These TypedDicts also lack other existing fields (enable_config_discovery, remote_session), making this a pre-existing gap rather than a regression. The runtime behavior is correct — client.py accepts and forwards the parameter. The follow-up to fill these TypedDicts is already noted in the PR description.

  2. Go EnableConfigDiscovery bool vs EnableOnDemandInstructionDiscovery *bool — The new field uses *bool (pointer) for optional semantics while the older EnableConfigDiscovery uses a bare bool. The PR description explicitly calls this out and defers retrofitting the existing field to avoid a breaking change. The new field's design (*bool) is the correct pattern (consistent with EnableSessionTelemetry *bool, IncludeSubAgentStreamingEvents *bool).

Conclusion

No new cross-SDK consistency issues introduced by this PR. The implementation correctly follows the precedents set by enableConfigDiscovery and remoteSession. Both acknowledged gaps are pre-existing and tracked for follow-up.

Generated by SDK Consistency Review Agent for issue #1323 · ● 2M ·

Comment thread dotnet/src/Types.cs
public bool? EnableConfigDiscovery { get; set; }

/// <summary>
/// When <see langword="true"/>, requests on-demand discovery of custom instruction
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "on-demand discovery" actually mean? Demanded by what / when, discovered where, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants